/**
 * 
 * Copyright 2013 by Hai Nguyen 
 *
 */

package com.avj.g17.chat.common.model;

import java.io.Serializable;
import java.util.Date;

/**
 * Message
 *
 * @author Hai Nguyen <hain186@gmail.com>
 * @version $Id: Message Jan 31, 2013 1:47:14 PM hainn $   
 */
public class Message implements Serializable{
    private User sender;
    private User recireceiver;
    private Date time;
    private String message;
    private FileAttach fileAttach;

    public Message() {
    }

    public Message(User sender, User recireceiver, String message) {
        this.sender = sender;
        this.recireceiver = recireceiver;
        this.time = new Date();
        this.message = message;
    }

    public User getSender() {
        return sender;
    }

    public void setSender(User sender) {
        this.sender = sender;
    }

    public User getRecireceiver() {
        return recireceiver;
    }

    public void setRecireceiver(User recireceiver) {
        this.recireceiver = recireceiver;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public FileAttach getFileAttach() {
        return fileAttach;
    }

    public void setFileAttach(FileAttach fileAttach) {
        this.fileAttach = fileAttach;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.sender != null ? this.sender.hashCode() : 0);
        hash = 67 * hash + (this.recireceiver != null ? this.recireceiver.hashCode() : 0);
        hash = 67 * hash + (this.time != null ? this.time.hashCode() : 0);
        hash = 67 * hash + (this.message != null ? this.message.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Message other = (Message) obj;
        if (this.sender != other.sender && (this.sender == null || !this.sender.equals(other.sender))) {
            return false;
        }
        if (this.recireceiver != other.recireceiver && (this.recireceiver == null || !this.recireceiver.equals(other.recireceiver))) {
            return false;
        }
        if (this.time != other.time && (this.time == null || !this.time.equals(other.time))) {
            return false;
        }
        if ((this.message == null) ? (other.message != null) : !this.message.equals(other.message)) {
            return false;
        }
        return true;
    }
    
    
}
